package com.example.demo.OtherCoding;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: sfx
 * Date: 2023-05-12
 * Time: 20:35
 */
public class Code_insertIntoBST {
    class Solution {
        public TreeNode insertIntoBST(TreeNode root, int val) {
            if (root == null) {
                return new TreeNode(val);
            }
            if (root.val > val) {
                root.left = insertIntoBST(root.left, val);
            }
            if (root.val < val) {
                root.right = insertIntoBST(root.right, val);
            }
            return root;
        }
    }
}
